package cn.ncupyh;

public class TankClass {
    //属性
    private String name;//名字
    private double speed;//速度
    private int bulletaAmount;//炮弹数量

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getSpeed() {
        return speed;
    }

    public void setSpeed(double speed) {
        this.speed = speed;
    }

    public int getBulletaAmount() {
        return bulletaAmount;
    }

    public void setBulletaAmount() {
        System.out.println(this.getName() + "的炮弹数量为:" + this.bulletaAmount);
//        this.bulletaAmount = bulletaAmount;
    }

    public TankClass(String name, double speed, int bulletaAmount) {
        this.name = name;
        this.speed = speed;
        this.bulletaAmount = bulletaAmount;
    }

    public TankClass() {
    }

    //    方法
    //加速
    public  void speedUp(double speed){
        this.setSpeed(speed);
        System.out.println(this.name + "的坦克加速!\n速度为:" + getSpeed());
    }

    //减速
    public  void speedDown(double speed){
        this.setSpeed(speed);
        System.out.println(this.name + "的坦克减速!\n速度为:" + getSpeed());
    }

//    显示速度
    public void PrintSpeed(double speed){
    System.out.println(this.name + "的速度为:" + speed);
}

//    开火
    public void fire(int num){
        System.out.println(this.getName() + "打出一发炮弹!");
        int newamount = getBulletaAmount() - 1;
        this.bulletaAmount =newamount;
    }
}
